package vip.xiaonuo.biz.modular.rewardslog.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 奖励类型枚举
 * @author hjl
 */
@Getter
@AllArgsConstructor
public enum RewardsTypeEnum {
    REPORT(0,"上报奖励"),
    RECOMMEND(1,"推荐奖励"),
    TASK(2,"盯防奖励"),
    SYS(3,"主动红包"),
    UNKNOW(99,"未知"),
    ;

    /**
     * 值
     */
    private Integer value;
    /**
     * 描述
     */
    private String desc;

    public static RewardsTypeEnum findByValue(Integer val) {
        return Arrays.stream(RewardsTypeEnum.values()).filter(item -> Objects.equals(val, item.getValue())).findFirst().orElse(UNKNOW);
    }

    public static String getNameByValue(Integer val) {
        return Arrays.stream(RewardsTypeEnum.values()).filter(item -> Objects.equals(val, item.getValue())).findFirst().orElse(UNKNOW).getDesc();
    }
}
